package org.jiuling.local.tools.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

/**
 * 输入流工具
 * @author 紫灵
 * @date 2021年12月02日 10时14分07秒
 */
@Deprecated
public class InputStreamUtil {

    /** 私有化构造方法，禁止创建对象 */
    private InputStreamUtil() {}

    /**
     * 读取输入流
     * @param inputStream 输入流
     * @return 读取的信息
     */
    public static String readInputStream(InputStream inputStream) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
        // 存放数据
        StringBuilder stringBuilder = new StringBuilder();
        String temp;
        while ((temp = bufferedReader.readLine()) != null) {
            stringBuilder.append(temp);
            stringBuilder.append("\r\n");
        }
        return stringBuilder.toString();
    }

}
